package com.ess.project.examine.record.compute;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:  30米×2蛇形跑 (秒，取1位小数)
 * 超出100分后每递减0.1秒增加1分
 * @Date: Created in 7:45 下午 2021/3/7
 * @Author: daihui
 * @Modified By:
 */
public class SnakeRunExamineStrategy implements BaseExamine<Float> {

    private static final Map<Integer, Integer[]> MAN_DIC_DATA = new HashMap<>(13);
    private static final Map<Integer, Integer[]> WOMAN_DIC_DATA = new HashMap<>(13);

    static {
        initDicData();
    }

    private static void initDicData(){
        Integer[] manGradeArray24   = {-21200, -20400, -20400, -20100, -20100, -19900, -19900, -19700, -19700, -19500, -19500, -19200, -19200, -19000, -19000, -18700, -18700, -18100, -18100, MAX_NUMBER};
        Integer[] manGradeArray2527 = {-21500, -20800, -20800, -20400, -20400, -20200, -20200, -20000, -20000, -19800, -19800, -19500, -19500, -19300, -19300, -18900, -18900, -18300, -18300, MAX_NUMBER};
        Integer[] manGradeArray2830 = {-21900, -21100, -21100, -20700, -20700, -20400, -20400, -20200, -20200, -20000, -20000, -19700, -19700, -19500, -19500, -19100, -19100, -18500, -18500, MAX_NUMBER};
        Integer[] manGradeArray3133 = {-22200, -21300, -21300, -21100, -21100, -20700, -20700, -20300, -20300, -20100, -20100, -19900, -19900, -19700, -19700, -19300, -19300, -18700, -18700, MAX_NUMBER};
        Integer[] manGradeArray3436 = {-22600, -21700, -21700, -21300, -21300, -20900, -20900, -20500, -20500, -20200, -20200, -20100, -20100, -19900, -19900, -19500, -19500, -18900, -18900, MAX_NUMBER};
        Integer[] manGradeArray3739 = {-22700, -21800, -21800, -21400, -21400, -21100, -21100, -20800, -20800, -20500, -20500, -20200, -20200, -20100, -20100, -19800, -19800, -19100, -19100, MAX_NUMBER};
        Integer[] manGradeArray4042 = {-22900, -22300, -22300, -21600, -21600, -21200, -21200, -21000, -21000, -20600, -20600, -20400, -20400, -20200, -20200, -20000, -20000, -19300, -19300, MAX_NUMBER};
        Integer[] manGradeArray4345 = {-23300, -22400, -22400, -21800, -21800, -21500, -21500, -21300, -21300, -20700, -20700, -20600, -20600, -20400, -20400, -20200, -20200, -19500, -19500, MAX_NUMBER};
        Integer[] manGradeArray4648 = {-23900, -22600, -22600, -22000, -22000, -21700, -21700, -21500, -21500, -20900, -20900, -20800, -20800, -20600, -20600, -20400, -20400, -19700, -19700, MAX_NUMBER};
        Integer[] manGradeArray4951 = {-24000, -22800, -22800, -22400, -22400, -21800, -21800, -21700, -21700, -21300, -21300, -21100, -21100, -20900, -20900, -20700, -20700, -19900, -19900, MAX_NUMBER};
        Integer[] manGradeArray5254 = {-24500, -23400, -23400, -22800, -22800, -22200, -22200, -22000, -22000, -21700, -21700, -21400, -21400, -21100, -21100, -20900, -20900, -20600, -20600, MAX_NUMBER};
        Integer[] manGradeArray5557 = {-24800, -23800, -23800, -23500, -23500, -23300, -23300, -22500, -22500, -22200, -22200, -22000, -22000, -21500, -21500, -21300, -21300, -21100, -21100, MAX_NUMBER};
        Integer[] manGradeArray5860 = {-25400, -24500, -24500, -24000, -24000, -23700, -23700, -23000, -23000, -22700, -22700, -22300, -22300, -22000, -22000, -21700, -21700, -21300, -21300, MAX_NUMBER};
        MAN_DIC_DATA.put(DATA_KEY_24, manGradeArray24);
        MAN_DIC_DATA.put(DATA_KEY_2527, manGradeArray2527);
        MAN_DIC_DATA.put(DATA_KEY_2830, manGradeArray2830);
        MAN_DIC_DATA.put(DATA_KEY_3133, manGradeArray3133);
        MAN_DIC_DATA.put(DATA_KEY_3436, manGradeArray3436);
        MAN_DIC_DATA.put(DATA_KEY_3739, manGradeArray3739);
        MAN_DIC_DATA.put(DATA_KEY_4042, manGradeArray4042);
        MAN_DIC_DATA.put(DATA_KEY_4345, manGradeArray4345);
        MAN_DIC_DATA.put(DATA_KEY_4648, manGradeArray4648);
        MAN_DIC_DATA.put(DATA_KEY_4951, manGradeArray4951);
        MAN_DIC_DATA.put(DATA_KEY_5254, manGradeArray5254);
        MAN_DIC_DATA.put(DATA_KEY_5557, manGradeArray5557);
        MAN_DIC_DATA.put(DATA_KEY_5860, manGradeArray5860);
        Integer[] womanGradeArray24   = {-22600, -22200, -22200, -21900, -21900, -21700, -21700, -21600, -21600, -21300, -21300, -21100, -21100, -20900, -20900, -20400, -20400, -20000, -20000, MAX_NUMBER};
        Integer[] womanGradeArray2527 = {-22900, -22500, -22500, -22200, -22200, -22000, -22000, -21900, -21900, -21600, -21600, -21400, -21400, -21200, -21200, -20700, -20700, -20300, -20300, MAX_NUMBER};
        Integer[] womanGradeArray2830 = {-23200, -22800, -22800, -22500, -22500, -22300, -22300, -22200, -22200, -21900, -21900, -21700, -21700, -21500, -21500, -21000, -21000, -20600, -20600, MAX_NUMBER};
        Integer[] womanGradeArray3133 = {-23500, -23100, -23100, -22800, -22800, -22600, -22600, -22500, -22500, -22200, -22200, -22000, -22000, -21800, -21800, -21300, -21300, -20900, -20900, MAX_NUMBER};
        Integer[] womanGradeArray3436 = {-23800, -23400, -23400, -23100, -23100, -22900, -22900, -22800, -22800, -22500, -22500, -22300, -22300, -22100, -22100, -21600, -21600, -21200, -21200, MAX_NUMBER};
        Integer[] womanGradeArray3739 = {-24100, -23700, -23700, -23400, -23400, -23200, -23200, -23100, -23100, -22800, -22800, -22600, -22600, -22400, -22400, -21900, -21900, -21500, -21500, MAX_NUMBER};
        Integer[] womanGradeArray4042 = {-24400, -24000, -24000, -23700, -23700, -23500, -23500, -23400, -23400, -23100, -23100, -22900, -22900, -22700, -22700, -22200, -22200, -21800, -21800, MAX_NUMBER};
        Integer[] womanGradeArray4345 = {-24700, -24300, -24300, -24000, -24000, -23800, -23800, -23700, -23700, -23400, -23400, -23200, -23200, -23000, -23000, -22500, -22500, -22100, -22100, MAX_NUMBER};
        Integer[] womanGradeArray4648 = {-25000, -24600, -24600, -24300, -24300, -24100, -24100, -24000, -24000, -23700, -23700, -23500, -23500, -23300, -23300, -22800, -22800, -22400, -22400, MAX_NUMBER};
        Integer[] womanGradeArray4951 = {-25300, -24900, -24900, -24600, -24600, -24400, -24400, -24300, -24300, -24000, -24000, -23800, -23800, -23600, -26300, -23100, -23100, -22700, -22700, MAX_NUMBER};
        Integer[] womanGradeArray5254 = {-25600, -25200, -25200, -24900, -24900, -24700, -24700, -24600, -24600, -24300, -24300, -24100, -24100, -23900, -23900, -23400, -23400, -23000, -23000, MAX_NUMBER};
        Integer[] womanGradeArray5557 = {-25900, -25500, -25500, -25200, -25200, -25000, -25000, -24900, -24900, -24600, -24600, -24400, -24400, -24200, -24200, -23700, -23700, -23300, -23300, MAX_NUMBER};
        Integer[] womanGradeArray5860 = {-26200, -25800, -25800, -25500, -25500, -25300, -25300, -25200, -25200, -24900, -24900, -24700, -24700, -24500, -24500, -24000, -24000, -23600, -23600, MAX_NUMBER};
        WOMAN_DIC_DATA.put(DATA_KEY_24, womanGradeArray24);
        WOMAN_DIC_DATA.put(DATA_KEY_2527, womanGradeArray2527);
        WOMAN_DIC_DATA.put(DATA_KEY_2830, womanGradeArray2830);
        WOMAN_DIC_DATA.put(DATA_KEY_3133, womanGradeArray3133);
        WOMAN_DIC_DATA.put(DATA_KEY_3436, womanGradeArray3436);
        WOMAN_DIC_DATA.put(DATA_KEY_3739, womanGradeArray3739);
        WOMAN_DIC_DATA.put(DATA_KEY_4042, womanGradeArray4042);
        WOMAN_DIC_DATA.put(DATA_KEY_4345, womanGradeArray4345);
        WOMAN_DIC_DATA.put(DATA_KEY_4648, womanGradeArray4648);
        WOMAN_DIC_DATA.put(DATA_KEY_4951, womanGradeArray4951);
        WOMAN_DIC_DATA.put(DATA_KEY_5254, womanGradeArray5254);
        WOMAN_DIC_DATA.put(DATA_KEY_5557, womanGradeArray5557);
        WOMAN_DIC_DATA.put(DATA_KEY_5860, womanGradeArray5860);
    }

    @Override
    public Integer compute(Object args, String gender, Float... grade) {
        int age = (int) args;
        // 转为毫秒（用整形计算方便）
        int ms = (int) -(grade[0] * 1000);
        Integer[] arr;
        if (MAN.equals(gender)) {
            arr = MAN_DIC_DATA.get(BaseExamine.dicKey(age));
        } else {
            arr = WOMAN_DIC_DATA.get(BaseExamine.dicKey(age));
        }
        return BaseExamine.getScore(ms, EXAMINATION_ITEM_SNAKE_RUN, arr);
    }
}
